package blackstar.plugin.ui.vo;

import java.util.ArrayList;
import java.util.List;

public class DetailInvokeStack
{
	private String className;
	private String methodName;
	private long totalInvokes;
	private double totalTime;
	private String percent; 
	private int level;
	private List<DetailInvokeStack> children = new ArrayList<DetailInvokeStack>();

	public DetailInvokeStack(String className, String methodName,
			long totalInvokes, double totalTime, String percent,  int level)
	{
		super();
		this.className = className;
		this.methodName = methodName;
		this.totalInvokes = totalInvokes;
		this.totalTime = totalTime;
		this.percent = percent;
		this.level = level;
	}
	
	public void addChild(DetailInvokeStack child)
	{
		if (child.level - this.level == 1)
		{
			children.add(child);
		}
		else if (children.size() > 0)
		{
			children.get(children.size()-1).addChild(child);
		}
	}

	public String getClassName()
	{
		return className;
	}

	public String getMethodName()
	{
		return methodName;
	}

	public long getTotalInvokes()
	{
		return totalInvokes;
	}

	public double getTotalTime()
	{
		return totalTime;
	}

	public String getPercent()
	{
		return percent;
	}

	public List<DetailInvokeStack> getChildren()
	{
		return children;
	}
}
